package com.example06.service.impl;

import com.example06.entity.Container;
import com.example06.entity.Freighter;
import com.example06.entity.MyException;
import com.example06.service.BusinessService;

import java.util.List;

public class BusinessServiceImpl  implements BusinessService {
    public void isOverweight(Freighter freighter, List<Container> containers) throws MyException{
        double totalWeight = 0;
        for (Container c : containers) {
            totalWeight = totalWeight + c.getWeight();
        }
        if(totalWeight > freighter.getTotalWeight()) {
            throw new MyException("超重");
        }
    }
}